﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jumpton.SFA.Server.BusinessRule.CallRoute;
using System.Data;
using Jumpton.SFA.Server.BusinessRule.InStoreDataMeasures;

public partial class Visit_KPI_Info : PageBase
{
    private decimal visitId;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            visitId = decimal.Parse(Request.QueryString["visitid"]);
        }
        catch (Exception)
        {
            return;
        }
        InitPage();
    }

    private void InitPage()
    {
        //绑定指标
        DataTable dt = MeasuresGroupItemDetailValueManager.GetMeasuresTransactionInfo(" AND V.ID='" + visitId + "'");
        DataTable dtMeasure = dt.Clone();
        foreach (DataRow row in dt.Rows)
        {
            if (dtMeasure.Select("MEASURE_ID='" + row["MEASURE_ID"].ToString() + "'").Count() < 1)
                dtMeasure.ImportRow(row);
        }
        rptMeasure.DataSource = dtMeasure;
        rptMeasure.DataBind();
    }
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //if (e.Row.RowType != DataControlRowType.DataRow)
        //    return;
        //DataRowView view = e.Row.DataItem as DataRowView;

        ////如果是照片，则显示该照片
        //if ((bool)view["ISPHOTO"] && "" != view["PHOTOID"].ToString())
        //{
        //    //HtmlAnchor a = new HtmlAnchor();
        //    //view["INPUTTYPE"].ToString() == "6"
        //    //Image image = new Image();
        //    //image.BorderStyle = BorderStyle.Solid;
        //    //image.Height = new Unit(80, UnitType.Pixel);
        //    //image.Width = new Unit(80, UnitType.Pixel);
        //    //image.ImageUrl = "../IMAGE.aspx?" + view["PHOTOID"].ToString();

        //    System.Text.StringBuilder sb = new System.Text.StringBuilder("");
        //    sb.Append("javascript:window.showModalDialog('ReadPhoto.aspx?id=");
        //    sb.Append(view["PHOTOID"].ToString());
        //    sb.Append("','','dialogHeight:660px;dialogWidth:660px;left='+(screen.width-100)/2+',top='+(screen.height-100)/2+',center:yes;help:no;status:no;toolbar:no;')");

        //    e.Row.Cells[1].Text += "&nbsp;&nbsp;&nbsp;&nbsp;<a href=" + sb.ToString() + ">查看照片</a>";
        //}
    }

    protected void rptMeasure_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            GridView gv = e.Item.FindControl("gvMeasureTransation") as GridView;
            string measureID = DataBinder.Eval(e.Item.DataItem, "MEASURE_ID").ToString();
            gv.DataSource = MeasuresGroupItemDetailValueManager.GetMeasuresTransactionInfo(" AND V.ID='" + visitId + "' AND MI.ID='" + measureID + "'");
            //gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
            gv.DataBind();

        }

    }
}